import request from '@/utils/request'
import axios from 'axios'

export function login(data) {
  return request({
    // url: '/vue-admin-template/user/login',
    url: '/online/authorization/auth/login',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/online/authorization/auth/user/info',
    method: 'get'
  })
}

export function getselfInfoFull() {
  return request({
    url: '/online/authorization/user-self/user/info',
    method: 'get'
  })
}

export function getAllUser(params) {
  return request({
    url: '/online/authorization/user/list/all',
    method: 'GET',
    params
  })
}

export function getUserPermission(userId) {
  return request({
    url: `/online/authorization/user/${userId}/menu-permission`,
    method: 'GET'
  })
}

export function updateUserInfoFull(data) {
  return request({
    url: '/online/authorization/user-self/user/info/update',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    // url: '/vue-admin-template/user/logout',
    url: '/online/authorization/auth/logout',
    method: 'post'
  })
}

export function authCaptcha() {
  return axios({
    url: '/online/authorization/auth/verify/code'
  })
}

export function getUserPage(params) {
  return request({
    url: '/online/authorization/user',
    method: 'GET',
    params
  })
}

export function lockUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}/lock`,
    method: 'POST'
  })
}

export function unlockUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}/unlock`,
    method: 'POST'
  })
}

export function addUser(data) {
  return request({
    url: `/online/authorization/user`,
    method: 'POST',
    data
  })
}

export function editUser(userId, data) {
  return request({
    url: `/online/authorization/user/${userId}`,
    method: 'POST',
    data
  })
}

export function editUserName(userId, data) {
  return request({
    url: `/online/authorization/user/${userId}/?updateRoleFlag=false`,
    method: 'POST',
    data
  })
}

export function getRamKey(userId, data) {
  return request({
    url: `/online/authorization/ram/security/${userId}/show`,
    method: 'POST',
    data
  })
}

export function resetRamKey(userId, data) {
  return request({
    url: `/online/authorization/ram/security/${userId}/reset`,
    method: 'POST',
    data
  })
}

export function getUser(userId) {
  return request({
    url: `/online/authorization/user/${userId}`,
    method: 'get'
  })
}


export function editUserEmail(data) {
  return request({
    url: `/online/authorization/user/email/update`,
    method: 'post',
    data
  })
}

export function verifyAuthCode(clearKey, data) {
  return request({
    url: `/online/authorization/user/auth-code/email/verify/${clearKey}`,
    method: 'post',
    data
  })
}

export function sendVerifyCode(data) {
  return request({
    url: `/online/authorization/user/auth-code/email`,
    method: 'post',
    data
  })
}

export function changePassword(data) {
  return request({
    url: `/online/authorization/auth/password/change`,
    method: 'POST',
    data
  })
}

export function getTimeStamp() {
  return request({
    url: `/online/authorization/auth/timestamp`
  })
}

export function resetPassword(userId) {
  return request({
    url: `/online/authorization/user/${userId}/reset/password`,
    method: 'POST'
  })
}

export function deleteUser(userId) {
  return request({
    url: `/online/management/operator/system/user/${userId}`,
    method: 'delete'
  })
}

// ��ѯĳ���û���ǰ��ƽ̨״̬
export function getUserPlatform(params) {
  return request({
    url: `online/authorization/user/platform/list`,
    method: 'GET',
    params:params
  })
}

// ��һ���û���ͨFlyCare
export function openTOMS(data) {
  return request({
    url: `online/authorization/user/platform`,
    method: 'POST',
    data:data
  })
}

// ��һ���û��ر�FlyCare
export function closeTOMS(userId) {
  return request({
    url: `online/authorization/user/platform/TOMS/user/${userId}`,
    method: 'DELETE',
  })
}

export function downloadDemoIdGuideInfo() {
  return request({
    url: `/online/management/file/static/manual/demo/download/get-url`,
    method: 'get'
  })
}
